home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-10-20 | 2.2 KB | 99 lines | [TEXT/MMCC] |
- // iomanip standard header
- #ifndef _IOMANIP_
- #define _IOMANIP_
- #include <istream>
- #include <ostream>
-
- #if __MWERKS__
- #pragma options align=mac68k
- #endif
-
- // template class smanip
- template<class _T> class smanip {
- public:
- smanip(ios& (*_F)(ios&, _T), _T _A)
- : _Pf(_F), _Manarg(_A) {}
- ios& (*_Pf)(ios&, _T);
- _T _Manarg;
- };
- template<class _T> inline
- istream& operator>>(istream& _I, const smanip<_T>& _M)
- { // apply manipulator to input stream
- _TRY_BEGIN
- (*_M._Pf)(_I, _M._Manarg);
- _CATCH_ALL
- _I.setstate(ios::failbit);
- _CATCH_END
- return (_I);
- }
- template<class _T> inline
- ostream& operator<<(ostream& _O, const smanip<_T>& _M)
- { // apply manipulator to output stream
- _TRY_BEGIN
- (*_M._Pf)(_O, _M._Manarg);
- _CATCH_ALL
- _O.setstate(ios::failbit);
- _CATCH_END
- return (_O);
- }
- // template class imanip
- template<class _T> class imanip {
- public:
- imanip(istream& (*_F)(istream&, _T), _T _A)
- : _Pf(_F), _Manarg(_A) {}
- istream& (*_Pf)(istream&, _T);
- _T _Manarg;
- };
- template<class _T> inline
- istream& operator>>(istream& _I, const imanip<_T>& _M)
- { // apply input manipulator to input stream
- _TRY_BEGIN
- (*_M._Pf)(_I, _M._Manarg);
- _CATCH_ALL
- _I.setstate(ios::failbit);
- _CATCH_END
- return (_I);
- }
- // template class omanip
- template<class _T> class omanip {
- public:
- omanip(ostream& (*_F)(ostream&, _T), _T _A)
- : _Pf(_F), _Manarg(_A) {}
- ostream& (*_Pf)(ostream&, _T);
- _T _Manarg;
- };
- template<class _T> inline
- ostream& operator<<(ostream& _O, const omanip<_T>& _M)
- { // apply manipulator to output stream
- _TRY_BEGIN
- (*_M._Pf)(_O, _M._Manarg);
- _CATCH_ALL
- _O.setstate(ios::failbit);
- _CATCH_END
- return (_O);
- }
- // instantiations
- smanip<ios::fmtflags> resetiosflags(ios::fmtflags);
- smanip<ios::fmtflags> setiosflags(ios::fmtflags);
- smanip<int> setbase(int);
- smanip<int> setfill(int);
- smanip<int> setprecision(int);
- smanip<int> setw(int);
-
- #if __MWERKS__
- #pragma options align=reset
- #endif
-
- #endif
-
- /*
- * Copyright (c) 1994 by P.J. Plauger. ALL RIGHTS RESERVED.
- * Consult your license regarding permissions and restrictions.
- */
-
- /* Change log:
- *94June04 PlumHall baseline
- *94Sept30 Applied diffs for Fri Aug 26 00:52:06 1994
- *94Oct07 Inserted MW changes.
- */
-